#include<iostream>
#include <fstream>
#include <string>
int main()
{
	using namespace std;
	ifstream fin("corner.msh");
	ofstream fout1("nod.dat");
	ofstream fout2("pat.dat");
	string buff;
	int n,row;
	while (fin>>buff && buff!="$Nodes");
	fin>>n;
	fout1<<n;
	row=1;
	for (int i=1;i<=n;i++)
	{
		fin>>buff;
		fout1<<endl<<row++<<"     ";
		for (int j=1;j<=3;j++)
		{
			double temp;
			fin>>temp;
			fout1<<temp<<"     ";
		}
	}
	
	fout1.close();
	while (fin>>buff && buff!="$Elements");
	fin>>n;
	row=1;
	for (int i=1; i<=n ;i++)
	{
		int temp, n1, n2, n3;
		fin>>temp>>temp;
		if (temp == 2)
		{
			fin>>temp>>temp>>temp>>n1>>n3>>n2;
			fout2<<row++<<"		"<<n1<<"	"<<n2<<"	"<<n3<<endl;
		}
		else if (temp == 1)
		{
			fin>>temp>>temp>>temp>>temp>>temp;
		}
		else
		{
			fin>>temp>>temp>>temp>>temp;
		}
	}
	fout2.close();
	fin.close();
	return 0;
}
